##########################################
models/Tables/{$tB}.php
##########################################
/**
 * $tb{LF}
 * $tn{LF}
 * @author Administrator
 * @version
 */
class Model_Tables_$tB extends Zend_Db_Table_Abstract {
    /**
     * The default table name
     */
    protected <!--$-->_name = '$tb';
    /**
     * add
     * 增加{$tn}{LF}
     * @param <!--$-->params 字段信息
     */
    public function add( <!--$-->params )
    {
        <!--$-->data = array({LF}
<!--{loop $result $k $info}-->
<!--{if $info["Key"]!="PRI"}-->
		'$info["Field"]' => <!--$-->params['$info["Field"]'],{LF}
<!--{/if}-->
<!--{/loop}-->
        );
        return <!--$-->this->insert(<!--$-->data);
    }
    /**
     * modify
     * 编辑{$tn}{LF}
     * @param <!--$-->params 字段信息
     * @param <!--$-->$pri 主键值
     */
    public function modify( <!--$-->params, <!--$-->$pri )
    {
        <!--$-->data = array({LF}
<!--{loop $result $k $info}-->
<!--{if $info["Key"]!="PRI"}-->
		'$info["Field"]' => <!--$-->params['$info["Field"]'],{LF}
<!--{/if}-->
<!--{/loop}-->
        );
        <!--$-->where = '$pri = '.<!--$-->$pri ;
        return <!--$-->this->update(<!--$-->data , <!--$-->where );
    }
    /**
     * modifyAjax
     * 无刷新编辑{$tn}{LF}
     * @param <!--$-->$pri 主键值
     * @param <!--$-->field 字段
     * @param <!--$-->value 值
     */
    public function modifyAjax( <!--$-->$pri, <!--$-->field, <!--$-->value )
    {
    	<!--$-->db = <!--$-->this->getAdapter();
    	<!--$-->data = array(<!--$-->field => <!--$-->value);
    	<!--$-->where = <!--$-->db->quoteInto("$pri=?", <!--$-->$pri);
        return <!--$-->this->update(<!--$-->data , <!--$-->where );
    }
    /**
     * modifyAjaxRevers
     * 无刷新字段反转{$tn}{LF}
     * @param <!--$-->field 需要反转的字段
     * @param <!--$-->$pri 主键值
     */
    public function modifyAjaxRevers( <!--$-->field ,<!--$-->pri)
    {
    	<!--$-->db = <!--$-->this->getAdapter();
    	<!--$-->sql = "update $tb set  <!--$-->field =not  <!--$-->field  where $pri=' <!--$-->pri'";
		return <!--$-->db->query(<!--$-->sql);
    }
    /**
     * del
     * 根据条件删除{$tn}{LF}
     * @param <!--$-->$pri 主键值
     */
    public function del( <!--$-->$pri )
    {
     	<!--$-->where = '$pri = '.<!--$-->$pri;
        return <!--$-->this->delete(<!--$-->where);
    }
    /**
     * getInfo
     * 获取{$tn}信息
     * @param <!--$-->$pri 主键值
     * @return 结果数组
     */
    public function getInfo(<!--$-->$pri)
    {
        <!--$-->row = <!--$-->this->fetchRow('$pri = ' . <!--$-->$pri);
        if (!<!--$-->row) {
        	return null;
        }
        else
        {
        	return <!--$-->row->toArray();
        }
    }
    /**
     * getCount
     * 获取{$tn}数量
     * @param int $s 搜索条件
     * @return 结果数
     */
    public function getCount(<!--$-->s = "",<!--$-->$tp=-1)
    { 
    	<!--$-->db = <!--$-->this->getAdapter();
    	<!--$-->$tp = intval(<!--$-->$tp);
    	<!--$-->where = <!--$-->db->quoteInto("$tp=?", <!--$-->$tp);
        <!--$-->select = <!--$-->this->select()->from(<!--$-->this->_name,'count(*) as num');
    	if(<!--$-->s!="")  
    	{
			<!--$-->where .= <!--$-->db->quoteInto(" and $pri=?", <!--$-->s);
    		<!--$-->select = <!--$-->select->where(<!--$-->where);
    	}
        <!--$-->result = <!--$-->this->fetchRow(<!--$-->select)->num;
        return <!--$-->result;
    }
    /**
     * getList
     * 取{$tn}数据分页
     * @param int $page 页码
     * @param int $numPerPage 每页的行数 
     * @param $s 搜索条件
     * @return 行数组
     */
    public function getList(<!--$-->page, <!--$-->numPerPage = 10,<!--$-->s= "",<!--$-->$tp=-1)
    {
    	<!--$-->db = <!--$-->this->getAdapter();
    	<!--$-->$tp = intval(<!--$-->$tp);
    	<!--$-->where = <!--$-->db->quoteInto("$tp=?", <!--$-->$tp);
    	<!--$-->page = (1><!--$-->page) ? 1 : <!--$-->page;
    	<!--$-->offset = (<!--$-->page-1)*<!--$-->numPerPage;
        <!--$-->orderby = array('$pri');
        if(<!--$-->s!="")     
		{
			<!--$-->where .= <!--$-->db->quoteInto(" and $pri= ?", <!--$-->s);
		}  
        <!--$-->result = <!--$-->this->fetchAll(<!--$-->where,<!--$-->orderby, <!--$-->numPerPage, <!--$-->offset )->toArray();
        return <!--$-->result;
    }
}



##########################################
views/templates/$tb.manage.html
##########################################
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="/styles/general.css"/>
<link rel="stylesheet" type="text/css" href="/styles/main.css"/>
<link rel="stylesheet" type="text/css" href="/styles/pager.css"/>
<script type="text/javascript" src="/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="/js/jquery.jeditable.mini.js"></script> 
<script type="text/javascript" src="/js/jquery.pager.js"></script> 
<script type="text/javascript" language="javascript">
var s="";
var pCount=1;
var page=1;
jQuery.fn.extend({
	  doAjax: function() {
		if($(this).attr("href").indexOf("delete")>0)
	  	{
			if(!confirm("确定删除吗?"))return false;
		}
		$.ajax({			
	        url: $(this).attr("href"),
	        cache: false,
	        success: function(html){
				PageClick(page);
	        }
	    });
	  }
	});
PageClick = function(pageclickednumber) {
	page = pageclickednumber;
	$.ajax({
        url: "/$tb/indexAjax/page/"+pageclickednumber+"/{$tp}/{<!--$-->{$tp}}/s/"+s+"/",
        cache: false,
        success: function(html){
            $("#divtablelist").html(html);
            $("#pager").pager({ pagenumber: pageclickednumber, pagecount: pCount, buttonClickCallback: PageClick });
            $('.{$tb}editable').editable('/$tb/modifyAjax/', {
            	indicator : '正在保存...',
            	tooltip   : '点击修改...',
            	onblur    : 'submit' 
            });
            $(".ajaxsubmit").click(
        			function(){
        			$(this).doAjax();
        			return false;
        			});
        }
    });
}
$(document).ready(function() {
	PageClick(1);
	$("#search").click(
			function(){
				s=encodeURIComponent($("#keyword").attr("value"));
				PageClick(1);
				}
			);
});
</script>
</head>
<body >
<h1>
<span class="action-span"><a href="/$tb/add/{$tp}/{<!--$-->{$tp}}">添加{$tn}</a></span>
<span class="action-span1">{$tn}管理</span>
<div style="clear:both"></div>
</h1>
<div class="form-div">
	<img src="/images/icon_search.gif" width="26" height="22" border="0" alt="SEARCH" />
    输入{$tn} <input type="text" name="keyword" id="keyword"/> <input type="button" id="search" value=" 搜索 " />
</div>

<div id='divtablelist'></div>
<div id="pager" style='align:center;' /></div>
<div style="clear:both"></div>
{t*!*emplate 'footer.html'}
</body>
</html>

##########################################
views/templates/ajax/$tb.manage.ajax.html
##########################################

<div class="list-div" id="listDiv">
<table cellpadding="0" cellspacing="1" class="table_list">
<tr>{LF}
<!--{loop $result $k $info}-->
<th>{$info["Comment"]}</td>{LF}
<!--{/loop}-->
<th>管理操作</th>
</tr>
<!--{l*!*oop <!--$-->infos <!--$-->k <!--$-->info}-->
<tr>{LF}
<!--{loop $result $k $info}-->
<!--{if $info["Key"]==""}-->
<!--{if $info["Type"]=="tinyint(1) unsigned"}-->
<td style="width:5%" class="align_c"><a class="ajaxsubmit"  href="/$tb/modifyajaxrevers/field/{$info['Field']}/pri/{<!--$-->info['$pri']}">{<!--$-->info['{$info["Field"]}']}</a></td>{LF}
<!--{else}-->
<td style="width:10%" class="{$tb}editable" id="$info['Field']|<!--$-->info['$pri']">{<!--$-->info['{$info["Field"]}']}</td>{LF}
<!--{/if}-->
<!--{else}-->
<td style="width:5%" class="align_c">{<!--$-->info['{$info["Field"]}']}</td>{LF}
<!--{/if}-->
<!--{/loop}-->
<td class="align_center_120">
<a href="/$tb/modify/{$tp}/{<!--$-->{$tp}}/$pri/{<!--$-->info['$pri']}"><img src="/images/manage/edit.gif" alt="编辑" title="编辑"/></a> | 
<a class="ajaxsubmit" href="/$tb/delete/$pri/{<!--$-->info['$pri']}"><img src="/images/manage/del.gif" alt="删除" title="删除"/></a> 
</td>
</tr>
<!--{/l*!*oop}-->
</table>
</div>
<script type="text/javascript" language="javascript">pCount =<!--$-->PageCount;</script>

##########################################
views/templates/{$tb}.add.html
##########################################

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css"  href="/styles/general.css"/>
<link rel="stylesheet" type="text/css" href="/styles/main.css"/>
<link rel="stylesheet" type="text/css" href="/styles/validator.css"/>
<script src="/js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="/js/formValidator.js" type="text/javascript" charset="UTF-8"></script>
<script src="/js/formValidatorRegex.js" type="text/javascript" charset="UTF-8"></script>
<script type="text/javascript">
$(document).ready(function(){{LF}
	$.formValidator.initConfig({formid:"myform",onerror:function(msg){alert(msg)}});{LF}
<!--{loop $result $k $info}-->
<!--{if $info["Key"]==""}-->
	$("#{$info['Field']}").formValidator({onshow:"请输入{$info['Comment']}",onfocus:"请至少要输入1个字符",oncorrect:"OK",defaultvalue:""}).inputValidator({min:1,onerror:"长度不正确,请确认"});{LF}
<!--{/if}-->
<!--{/loop}-->
});
</script>
<title></title>
</head>
<body>
<h1>
<span class="action-span"><a href="/{$tb}/index/{$tp}/{<!--$-->{$tp}}">管理{$tn}</a></span>
<span class="action-span1"> 添加{$tn}</span>
<div style="clear:both"></div>
</h1>
<div class="main-div">
  <form action="/$tb/add/{$tp}/{<!--$-->{$tp}}" method="post" name="myform" id="myform" enctype="multipart/form-data">
  <table width="100%" id="table_form">{LF}
<!--{loop $result $k $info}-->
<!--{if $info["Key"]!="PRI"}-->
      <tr>{LF}
        <td class="label">{$info["Comment"]}：</td>{LF}
        <td>{LF}
<!--{if $info["Type"]=="datetime"}-->
			{f*!*orm datetime * $info["Field"] $info["Field"] * * *}{LF}
<!--{elseif $info["Type"]=="tinyint(1) unsigned"}-->
			{f*!*orm radio * $info["Field"] $info["Field"] * * *}{LF}
<!--{else}-->
			{f*!*orm text * $info["Field"] $info["Field"]}{LF}
<!--{/if}-->
        </td>{LF}
        <td><div id='{$info["Field"]}Tip' style="width:250px"></div></td>{LF}
      </tr>{LF}
<!--{/if}-->
<!--{/loop}-->
  </table>  
   <div class="button-div">
        <input type="submit" value="&nbsp;确&nbsp;定&nbsp;" />
        &nbsp;&nbsp;&nbsp;&nbsp;
        <input type="reset" value="&nbsp;重&nbsp;置&nbsp;" />
   </div>
  </form>
</div>
{t*!*emplate 'footer.html'}
</body>
</html>


##########################################
views/templates/{$tb}.edit.html
##########################################

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="/styles/general.css"/>
<link rel="stylesheet" type="text/css" href="/styles/main.css" />
<link rel="stylesheet" type="text/css" href="/styles/validator.css"></link>
<script src="/js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="/js/formValidator.js" type="text/javascript" charset="UTF-8"></script>
<script src="/js/formValidatorRegex.js" type="text/javascript" charset="UTF-8"></script>
<script type="text/javascript">
$(document).ready(function(){{LF}
	$.formValidator.initConfig({formid:"myform",onerror:function(msg){alert(msg)}});{LF}
<!--{loop $result $k $info}-->
<!--{if $info["Key"]==""}-->
	$("#{$info['Field']}").formValidator({onshow:"请输入{$info['Comment']}",onfocus:"请至少要输入1个字符",oncorrect:"OK",defaultvalue:""}).inputValidator({min:1,onerror:"长度不正确,请确认"});{LF}
<!--{/if}-->
<!--{/loop}-->
});
</script>
<title></title>
</head>
<body>
<h1>
<span class="action-span"><a href="/{$tb}/index/{$tp}/{<!--$-->{$tp}}">管理$tn</a></span>
<span class="action-span1">修改$tn </span>
<div style="clear:both"></div>
</h1>
<div class="main-div">
  <form action="/$tb/modify/{$tp}/{<!--$-->{$tp}}" method="post" name="myform" id="myform" enctype="multipart/form-data">
  <input name='$pri' id='$pri' type="hidden" value="<!--$-->$pri" /> 
  <table width="100%" id="general-table">{LF}
<!--{loop $result $k $info}-->
<!--{if $info["Key"]!="PRI"}-->
     <tr>{LF}
        <td class="label">{$info["Comment"]}：</td>{LF}
        <td>{LF}
<!--{if $info["Type"]=="datetime"}-->
			{f*!*orm datetime * $info["Field"] $info["Field"] <!--$-->info['$info["Field"]']}{LF}
<!--{elseif $info["Type"]=="tinyint(1) unsigned"}-->
			{f*!*orm radio * $info["Field"] $info["Field"] <!--$-->info['$info["Field"]']}{LF}
<!--{else}-->
			{f*!*orm text * $info["Field"] $info["Field"] <!--$-->info['$info["Field"]']}{LF}
<!--{/if}-->
        </td>{LF}
        <td><div id='{$info["Field"]}Tip' style="width:250px"></div></td>{LF}
     </tr>{LF}
<!--{/if}-->
<!--{/loop}-->
  </table>
  
   <div class="button-div">
        <input type="submit" value="&nbsp;确&nbsp;定&nbsp;" />
        &nbsp;&nbsp;&nbsp;&nbsp;
        <input type="reset" value="&nbsp;重&nbsp;置&nbsp;" />
   </div>
      
  </form>
</div>
{t*!*emplate 'footer.html'}
</body>
</html>

##########################################
controllers/{$tB}Controller.php
##########################################
/** Zend_Controller_Action */ 
require_once APPLICATION_PATH . '/../library/Soooner/Controller/Action.php';
class {$tB}Controller extends Soooner_Controller_Action
{
	private <!--$-->_$pri;
	private <!--$-->_model$tB;
    public function init()
    {
        /* Initialize action controller here */
    	<!--$-->this->initDzTemplate();
    	<!--$-->this->_model$tB = new Model_Tables_$tB();
    }
    /**
    * 获取{$tn}列表{LF}
    * @return unknown_type
    */
    public function indexAction()
    {
    	/*<!--$-->options = <!--$-->GLOBALS['application']->getOptions();
    	<!--$-->numPerPage = <!--$-->options["pagecount"];//每页显示的条数
        <!--$-->ItemCount =  <!--$-->this->_model$tB->getCount();
        <!--$-->PageCount = ceil(<!--$-->ItemCount/<!--$-->numPerPage);
        <!--$-->PageCount = <!--$-->PageCount ? <!--$-->PageCount : 1;*/
        <!--$-->{$tp} = <!--$-->this->_getParam('{$tp}');
        include <!--$-->this->_dzTemplate->getFile( '$tb.manage.html' );
    }
    /**
    * 获取{$tn}列表{LF}
    * @return unknown_type
    */
    public function indexajaxAction()
    {
    	<!--$-->{$tp} = <!--$-->this->_getParam('{$tp}');
        <!--$-->options = <!--$-->GLOBALS['application']->getOptions();
    	<!--$-->numPerPage = <!--$-->options["pagecount"];//每页显示的条数
        <!--$-->page = intval(<!--$-->this->_getParam('page'));//默认页码
        <!--$-->page = empty(<!--$-->page)?'1':<!--$-->page;
   		<!--$-->s = <!--$-->this->_getParam('s'); 
        <!--$-->ItemCount =  <!--$-->this->_model$tB->getCount(<!--$-->s);
        <!--$-->PageCount = ceil(<!--$-->ItemCount/<!--$-->numPerPage);
        if(<!--$-->page><!--$-->PageCount)<!--$-->page=<!--$-->PageCount;
        <!--$-->infos = <!--$-->this->_model$tB->getList( <!--$-->page, <!--$-->numPerPage, <!--$-->s,<!--$-->{$tp} );
        include <!--$-->this->_dzTemplate->getFile( 'ajax/$tb.manage.ajax.html' );
    }
    /**
    * 添加$tn{LF}
    * @return unknown_type
    */
    public function addAction()
    {
    	<!--$-->{$tp} = <!--$-->this->_getParam('{$tp}');
    	<!--$-->request = <!--$-->this->getRequest();        
        if (<!--$-->request->isPost())
        {
            <!--$-->params =<!--$-->request->getPost();
            <!--$-->this->_model$tB->add(<!--$-->params);                
            <!--$-->this->_redirect("/$tb/index/{$tp}/{<!--$-->{$tp}}");
        } 
        include <!--$-->this->_dzTemplate->getFile( '$tb.add.html' );
    }
    /**
    * 修改$tn{LF}
    * @return unknown_type
    */
    public function modifyAction()
    {
    	<!--$-->{$tp} = <!--$-->this->_getParam('{$tp}');
    	<!--$-->$pri = <!--$-->this->_getParam('$pri');
    	<!--$-->info = <!--$-->this->_model$tB->getInfo(<!--$-->$pri); 
        <!--$-->request = <!--$-->this->getRequest();        
        if (<!--$-->request->isPost())
        {
        	<!--$-->request =<!--$-->request->getPost();        	
            if (true)//服务端检查输入参数
            {
                <!--$-->this->_model$tB->modify(<!--$-->request,<!--$-->$pri);
                <!--$-->this->_redirect("/$tb/index/{$tp}/".<!--$-->info["{$tp}"]);
            }
        } 
        include <!--$-->this->_dzTemplate->getFile( '$tb.edit.html' );
    }
    /**
    * 无刷新修改$tn{LF}
    * @return unknown_type
    */    
    public function modifyajaxAction()
    {
        <!--$-->request = <!--$-->this->getRequest();
        <!--$-->params = <!--$-->request->getPost();
        <!--$-->arr = split("\|", <!--$-->params['id']);
        <!--$-->field = <!--$-->arr[0];
        <!--$-->$pri = <!--$-->arr[1];
        <!--$-->value = stripslashes(<!--$-->params['value']);
        <!--$-->this->_model$tB->modifyAjax(<!--$-->$pri,<!--$-->field,<!--$-->value);
        echo <!--$-->value;
        exit;
    }
    public function modifyajaxreversAction()
    {
    	<!--$-->field = <!--$-->this->_getParam('field');
    	<!--$-->pri = <!--$-->this->_getParam('pri');
        <!--$-->this->_model$tB->modifyAjaxRevers(<!--$-->field,<!--$-->pri);
        exit;
    }
    /**
    * 删除$tn{LF}
    */
    public function deleteAction()
    {
        <!--$-->$pri = <!--$-->this->_getParam('$pri');   
        <!--$-->this->_model$tB->del(<!--$-->$pri); 
        exit;
    }
}

##########################################
结束
##########################################




